// globals
float4x4	World;
float4x4	gWVP;
float4x4	transform;
float		scaleValue;
float4		gColor;
texture		imageTexture;

	
sampler tex
{
	Texture = <imageTexture>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU = WRAP;
	AddressV = WRAP;
};
// Define a vertex shader output structure;
struct OutputVS
{
    float4 posH:POSITION0;
    float4 normal:COLOR0;
    float2 texCoord0: TEXCOORD0;
    float2 depth: TEXCOORD1;
};

struct OutputPS
{
	float4 color: COLOR0;
	float4 normal: COLOR1;
	half4 depth: COLOR2;
};

// Vertex shader -------------------------------------------------------------------------------------
OutputVS TransformVS( float3 position:POSITION0, float2 uv: TEXCOORD0, float3 normal: COLOR0 )
{
	// output structure
	OutputVS outVS;
	
	// scale the triangle
	outVS.posH = mul( float4( position, 1.0f ), gWVP );
	outVS.normal = mul( float4( normal, 1.0f ), World );
	outVS.texCoord0 = uv;
	outVS.depth.x = outVS.posH.z;
	outVS.depth.y = outVS.posH.w;
	
    return outVS;
}


// Pixel Shader ---------------------------------------------------------------------------
OutputPS TransformPS( OutputVS outVS )
{
	// change the color of the triangle
	OutputPS outPS;
	
	outPS.color = tex2D( tex, outVS.texCoord0 );
	outPS.depth = outVS.depth.x / outVS.depth.y;
	outPS.normal = outVS.normal;
	
	return outPS;
}

// ----------------------------------------------------------------------------------------
technique Basic
{
    pass P0
    {
        vertexShader = compile vs_2_0 TransformVS();
        pixelShader  = compile ps_2_0 TransformPS();
      
		ShadeMode = Gouraud;
		
        //FillMode = WIREFRAME;
        
        CullMode = CW;
    }
}
